/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PatientAdministrationManaged;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 * @author Swarit
 */
public class Input {
    
        public String getString(String attrName, String oldValue){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String stringValue= null;

        try{
            while(true){
                System.out.println("Enter " + attrName + (oldValue==null?"":"("+ oldValue+ ")")+" : ");
                stringValue = br.readLine ();
                if(stringValue.length()!=0){
                    break;
                    }
                else
                    if (stringValue.length()==0 && oldValue !=null)
                    {stringValue = oldValue;
                     break;
                    }
                System.out.println("Invalid" + attrName+ "...");
            }//end while
        }catch (Exception ex){
            System.out.println("\nERROR: " + ex.getMessage());
        }
        return stringValue.trim();
    }
    
}